package com.henu.tanhang;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.henu.R;
import com.henu.tanhang.entity.Detail;

import java.util.Random;

public class DetailActivity extends AppCompatActivity {

    private ImageView iv_detail;
    private TextView et_detailname;
    private TextView et_detailaddress;
    private TextView et_detailphone;
    private Detail details;
    private ImageButton shop;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);

        Intent intent = getIntent();
        details =(Detail)intent.getSerializableExtra("detail");
        System.out.println(details);

        iv_detail = (ImageView) findViewById(R.id.iv_detail);
        et_detailname = (TextView) findViewById(R.id.et_detailname);
        et_detailaddress = (TextView) findViewById(R.id.et_detailaddress);
        et_detailphone = (TextView) findViewById(R.id.et_detailphone);
        shop = (ImageButton) findViewById(R.id.shop);
        shop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        Random random = new Random();
        int i = random.nextInt(6)+1;

        if(i%7 == 0){
            iv_detail.setImageResource(R.drawable.hotel1);
        }else if(i%7 == 1){
            iv_detail.setImageResource(R.drawable.hotel2);
        }else if(i%7 == 2){
            iv_detail.setImageResource(R.drawable.hotel3);
        }else if(i%7 == 3){
            iv_detail.setImageResource(R.drawable.hotel4);
        }else if(i%7 == 4){
            iv_detail.setImageResource(R.drawable.hotel5);
        }else if(i%7 == 5){
            iv_detail.setImageResource(R.drawable.hotel6);
        }else if(i%7 == 6){
            iv_detail.setImageResource(R.drawable.hotel7);
        }

        et_detailname.setText(details.getCheckname());
        et_detailaddress.setText(details.getAddress());
        et_detailphone.setText(details.getPhone());
    }
}
